package jwlee.testproxy;

//回调机制
public class CallbackTester {
	public static void calcExecuteTime(Callback call) {
		long start = System.currentTimeMillis();
		System.out.println("----start...");
		
		call.execute();//
		
		long end = System.currentTimeMillis();
		System.out.println("----end. " + (end - start) + "ms");
	}

	public static void main(String[] s) {
		calcExecuteTime(new Counter());
	}
}

interface Callback {
	public void execute();
}

class Counter implements Callback {
	@Override
	public void execute() {
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
